﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace ApartmentBillsManager.Start.Converters
{
    class DateTimeNormalizer : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DateTime date;

            if (DateTime.TryParse(value.ToString(), out date))
            {
                if (date == DateTime.MinValue.Date || date == DateTime.MaxValue.Date)
                    return "---";

                return date.ToString("dd/MM/yy");
            }

            return "unsupported date";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
